﻿<local:BaseListWithToolbarContentFrame x:Class="InfFront.InfoViews.WPF.DataGridFrame"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InfFront.InfoViews.WPF"
    xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
    Height="Auto" Width="Auto" MinWidth="300" MinHeight="300"
    >

    <UserControl.Resources>
        <local:BoolNotConverter x:Key="boolNot"/>

        <Style x:Key="defaultRowStyle" TargetType="{x:Type dg:DataGridRow}">
            <Setter Property="Background" Value="Transparent"/>
        </Style>

        <!--
          SINGLE CLICK EDITING
        -->
        <Style TargetType="{x:Type dg:DataGridCell}">
            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown"></EventSetter>
        </Style>
    </UserControl.Resources>

    <dg:DataGrid x:Name="dataGrid"                      
                     AutoGenerateColumns="True"                                                            
                     IsSynchronizedWithCurrentItem="True" 
                     RowHeaderWidth="25"
                     ItemContainerStyle="{StaticResource defaultRowStyle}"
                     SelectionChanged="dataGrid_SelectionChanged"
                     MouseDoubleClick="dataGrid_MouseDoubleClick"
                     AutoGeneratingColumn="dataGrid_AutoGeneratingColumn"
                     IsReadOnly="{Binding Path=AllowsInplaceEdit, FallbackValue=False, Converter={StaticResource boolNot}}" 
                     SelectionUnit="FullRow">
        <dg:DataGrid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Offset="0" Color="{Binding Path=VisualSettings.PrimaryGridColor, FallbackValue=White}"/>
                <GradientStop Offset="1" Color="{Binding Path=VisualSettings.SecondaryGridColor, FallbackValue=Azure}"/>
            </LinearGradientBrush>
        </dg:DataGrid.Background>
    </dg:DataGrid>
</local:BaseListWithToolbarContentFrame>
